/**
 * 
 * If you have edited the file, please update
 * all the last-modified fields manually. Thanks!
 *
 * @last-modified by: 
 * @last-modified date: 
 * @last-modified time: 
 *
 * @author Swee Zhi
 * @date-created Sep 26, 2011    @time-created 11:50:43 PM
 *
 * @project: 
 * @module: 
 * @institution: 
 *
 */
package util.generator;

import javax.faces.context.FacesContext;
import org.primefaces.component.menuitem.MenuItem;
import org.primefaces.model.DefaultMenuModel;
import org.primefaces.model.MenuModel;
import util.localization.MenuLocalization;

public class TouristMenuGenerator {
    private MenuModel model;
    private MenuLocalization menuLocalization;
            
    public TouristMenuGenerator () {
        model = new DefaultMenuModel();
        menuLocalization = new MenuLocalization();
    }
    
    public MenuModel generateTouristNavMenu() {
        MenuItem menu1 = new MenuItem();
        menu1.setValue(menuLocalization.getTouristMenuItem("VIEW_MY_FOODSAGE"));
        menu1.setUrl("/tourist/TouristViewMyFoodSage.xhtml");
        model.addMenuItem(menu1);

        MenuItem menu2 = new MenuItem();
        menu2.setValue(menuLocalization.getTouristMenuItem("INACTIVATE_MY_FOODSAGE"));
        menu2.setUrl("/tourist/TouristInactivateMyFoodSage.xhtml");
        model.addMenuItem(menu2);
        
        MenuItem menu3 = new MenuItem();
        menu3.setValue(menuLocalization.getTouristMenuItem("PLAN_MY_TRIP"));
        menu3.setUrl("/itinerary/ItineraryChooseItineraryType.xhtml");
        model.addMenuItem(menu3);
        
        MenuItem menu4 = new MenuItem();
        menu4.setValue(menuLocalization.getTouristMenuItem("VIEW_MY_ITINERARIES"));
        menu4.setUrl("/itinerary/ItineraryViewAllTripItineraries.xhtml");
        model.addMenuItem(menu4);
        
        return model;
    }
    
    // for generating main menu (the horizontal one but not logged in) for all public pages
    public MenuModel generateTouristPublicMainMenu() {
        
        String serverName = FacesContext.getCurrentInstance().getExternalContext().getRequestServerName();
        int serverPort = (Integer) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("serverPort");
        String contextPath = FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath();

        MenuItem menu1 = new MenuItem();
        menu1.setValue(menuLocalization.getTouristMenuItem("HOME"));
        String URL = "http://" + serverName + ":" + serverPort + contextPath + "/index.xhtml";
        menu1.setUrl(URL);
        model.addMenuItem(menu1);
        
        MenuItem menu2 = new MenuItem();
        menu2.setValue(menuLocalization.getTouristMenuItem("RESTAURANTS"));
        menu2.setUrl("#");
        model.addMenuItem(menu2);

        MenuItem menu3 = new MenuItem();
        menu3.setValue(menuLocalization.getTouristMenuItem("PLACES_OF_INTEREST"));
        menu3.setUrl("#");
        model.addMenuItem(menu3);
        
        MenuItem menu4 = new MenuItem();
        menu4.setValue(menuLocalization.getTouristMenuItem("ITINERARY_PLANNER"));
        menu4.setUrl("#");
        model.addMenuItem(menu4);
        
        return model;
    }
    
    // for generating main menu (for all authenticated pages)
    public MenuModel generateTouristMainMenu() {
        MenuItem menu1 = new MenuItem();
        menu1.setValue(menuLocalization.getTouristMenuItem("HOME"));
        menu1.setUrl("../index.xhtml");
        model.addMenuItem(menu1);
        
        MenuItem menu2 = new MenuItem();
        menu2.setValue(menuLocalization.getTouristMenuItem("RESTAURANTS"));
        menu2.setUrl("#");
        model.addMenuItem(menu2);

        MenuItem menu3 = new MenuItem();
        menu3.setValue(menuLocalization.getTouristMenuItem("PLACES_OF_INTEREST"));
        menu3.setUrl("#");
        model.addMenuItem(menu3);
        
//        MenuItem menu4 = new MenuItem();
//        menu4.setValue(menuLocalization.getTouristMenuItem("ITINERARY_PLANNER"));
//        menu4.setUrl("#");
//        model.addMenuItem(menu4);
        
        return model;
    }

}
